package uk.ac.bath.gui;
import uk.ac.bath.util.*;
import javax.swing.*;
import javax.swing.event.*;

class SpinTweaker_1 extends JPanel implements ChangeListener {

    
    Tweakable t;
    SpinnerNumberModel model;
    
    SpinTweaker_1(TweakerPanel_1 p,Tweakable t) {
	this.t=t;

	model=
	    new SpinnerNumberModel(t.getNumber(),(Comparable)t.getMinimum(),
				   (Comparable)t.getMaximum(),
				   t.getStepSize());
	JSpinner spin=new JSpinner(model);
// 	model =   (SpinnerNumberModel)spin.getModel();
// 	model.setValue(t.getNumber());
// 	model.setMinimum((Comparable)t.getMinimum());
// 	model.setMaximum((Comparable)t.getMaximum());

	spin.addChangeListener(this);

 	p.add(new JLabel(t.getLabel()),spin);
    }


    public void stateChanged(ChangeEvent e) {
//	System.out.println(" HI" );
	t.set(model.getNumber());
	model.setValue(t.getNumber());
    }
}
